﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ColorWheel.Controls;
using ColorWheel.Core;

namespace ColorWheel.Wizard.Demo
{
    public partial class MainPage : UserControl
    {
        ColorPaletteWindow cpw = new ColorPaletteWindow();
        Palette palette;

        public MainPage()
        {
            InitializeComponent();

            int i = 0;

            string[] colors = new string[] 
            { 
                "Selection", "Error", "Title", "InputSelection", "Warning"
            };

            InitializeComponent();

            palette = Palette.Create(null, Colors.Blue);
            foreach (PaletteColor c in palette.Colors)
            {
                c.Name = colors[i++];
            }


            this.DataContext = this;

            cpw.Palette = palette;
            cpw.OnOK += CpwOnOK;

            this.Loaded += (s, e) => cpw.Show();
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
        }

        private void Button_Click(
            object sender,
            RoutedEventArgs e
        )
        {
            cpw.Show();
        }

        private void CpwOnOK(
            object sender,
            EventArgs e
        )
        {
            this.DataContext = null;
            this.DataContext = this;
        }

        public Brush PageForegroundWarning
        {
            get
            {
                return palette.Colors[4].Color.ToColor().ToBrush();
            }
        }

        public Brush PageForegroundLink
        {
            get
            {
                return palette.Colors[3].Color.ToColor().ToBrush();
            }
        }

        public Brush PageForegroundTitle
        {
            get
            {
                return palette.Colors[2].Color.ToColor().ToBrush();
            }
        }

        public Brush PageForeground
        {
            get
            {
                return palette.Colors[1].Color.ToColor().ToBrush();
            }
        }

        public Brush PageBackground
        {
            get
            {
                return palette.Colors[0].Color.ToColor().ToBrush();
            }
        }
    }
}

